package com.yaowk.sfp.test.service.impl.base;

import com.yaowk.sfp.test.service.IEntity1Service;
import com.yaowk.sfp.test.dao.Entity1Dao;
import com.yaowk.sfp.test.entity.TEntity1;
import java.lang.Long;
import com.yaowk.sfp.test.model.Entity1;
import org.springframework.beans.factory.annotation.Autowired;
import com.yaowk.sfp.common.db.BaseServiceImpl;
import java.lang.String;

public abstract class Entity1ServiceBase extends BaseServiceImpl<Entity1, TEntity1, Long> implements IEntity1Service {

	@Autowired
	private Entity1Dao dao;

	@Override public Entity1Dao getDao() {
	return dao;
	}

	@Override
	public Entity1 entity2Model(TEntity1 entity) {
		Entity1 model = null;
		if(isNotEmpty(entity)){
			model = new Entity1();
			model.setId(entity.getId());
			model.setParam1(entity.getParam1());
			model.setParam2(entity.getParam2());
			model.setParam3(entity.getParam3());
		}
		return model;
	}

	@Override
	public TEntity1 model2Entity(Entity1 model) {
		TEntity1 entity = null;
		if(isNotEmpty(model)){
			entity = new TEntity1();
			entity.setId(model.getId());
			entity.setParam1(model.getParam1());
			entity.setParam2(model.getParam2());
			entity.setParam3(model.getParam3());
		}
		return entity;
	}

	@Override
	public TEntity1 updateParams(Entity1 model) {
		TEntity1 entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getParam1()))
			entity.setParam1(model.getParam1());
		if(isNotEmpty(model.getParam2()))
			entity.setParam2(model.getParam2());
		if(isNotEmpty(model.getParam3()))
			entity.setParam3(model.getParam3());
		return entity;
	}


}